package com.bw.launcher.gateway

import com.bw.common.mvi.BaseViewModel
import com.bw.launcher.R
import com.bw.launcher.gateway.entity.GatewayEntity
import com.bw.launcher.gateway.entity.GatewayState
import java.util.ArrayList

class GatewayViewModel : BaseViewModel<GatewayRepo,GatewayState>(){

    private val iconsArray = arrayOf(R.drawable.icon32,R.drawable.icon32,R.drawable.icon140,
        R.drawable.icon829,R.drawable.icon359,
        R.drawable.icon1353,R.drawable.icon3)
    private val titleArray = arrayOf("在线应用","本地应用","考勤打卡","智能审批","工作日志",
        "任务","文件")
    private val pathArray = arrayOf("/apps/NetAppsActivity",
        "/apps/LocalAppsActivity",
        "/attendance/signactivity",
        "智能审批","工作日志",
        "任务","文件")
    private val iconsIMArray = arrayOf(R.drawable.icon1887,R.drawable.icon1622,
        R.drawable.icon1904)
    private val titleIMArray = arrayOf("联系人","讨论组","组织架构")
    private val pathIMArray = arrayOf("联系人","讨论组","组织架构")
    override fun createRepo(): GatewayRepo {
        return GatewayRepo()
    }

    override fun createState(): GatewayState {
        val datas = ArrayList<GatewayEntity>()
        return GatewayState(datas)
    }

    fun createData(){
        val datas = ArrayList<GatewayEntity>()
        val titleEntity1 = GatewayEntity("应用",R.drawable.icon1382,"",100)
        datas.add(titleEntity1)
        var index = 0
        while (index < iconsArray.size){
            val entity = GatewayEntity(titleArray.get(index),
                iconsArray[index], pathArray[index],200)
            datas.add(entity)
            index++
        }
        val titleEntity2 = GatewayEntity("通信",R.drawable.icon1488,"",100)
        datas.add(titleEntity2)
        index = 0
        while (index < iconsIMArray.size){
            val entity = GatewayEntity(
                titleIMArray[index],
                iconsIMArray[index], pathIMArray[index],200)
            datas.add(entity)
            index++
        }
        mutableContainer.updateUiState { copy(tabs = datas) }
    }

}